﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using AKMII.DMRA.Common;
using AKMII.DMRA.Business.Management;
using AKMII.DMRA.Business.Rule;

namespace AKMII.DMRA.Web
{
    public partial class Admin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGridView();
            }
        }

        private void BindGridView()
        {
            AccountManager am = new AccountManager();
            List<MarketDirector> mds = am.GetMarketDirectorSummary(CurrentPeriod.Year);
            GridView1.DataSource = mds;
            GridView1.DataBind();
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                for (int j = 1; j <= 12; j++)
                {
                    if (GridView1.Rows[i].Cells[j + 3].Controls[1].GetType().Name == "CheckBox")
                    {
                        CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[j + 3].Controls[1];
                        switch (j)
                        {
                            case 1:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInJan;
                                break;
                            case 2:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInFeb;
                                break;
                            case 3:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInMar;
                                break;
                            case 4:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInApr;
                                break;
                            case 5:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInMay;
                                break;
                            case 6:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInJun;
                                break;
                            case 7:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInJul;
                                break;
                            case 8:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInAug;
                                break;
                            case 9:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInSep;
                                break;
                            case 10:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInOct;
                                break;
                            case 11:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInNov;
                                break;
                            case 12:
                                cb.Checked = mds[GridView1.PageSize * GridView1.PageIndex + i].IsOrderInDec;
                                break;
                        }
                    }

                }
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindGridView();
        }
    }
}
